// src/test/java/org/nextcore/common/ResultsTest.java
package org.nextcore.common;

import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;

/**
 * Author：Fromsko
 * Results 类的单元测试
 */
public class ResultsTest {

    @Test
    public void testSuccessSingleData() {
        String data = "test data";
        Results<String> result = Results.success(data);
        assertThat(result.getCode()).isEqualTo(Results.ResultCode.SUCCESS.getCode());
        assertThat(result.getMessage()).isEqualTo(Results.ResultCode.SUCCESS.getMessage());
        assertThat(result.getData()).isEqualTo(data);
    }

    @Test
    public void testSuccessMultipleData() {
        List<String> dataList = Arrays.asList("data1", "data2");
        Results<String> result = Results.success(dataList);
        assertThat(result.getCode()).isEqualTo(Results.ResultCode.SUCCESS.getCode());
        assertThat(result.getMessage()).isEqualTo(Results.ResultCode.SUCCESS.getMessage());
        assertThat(result.getDataList()).isEqualTo(dataList);
    }

    @Test
    public void testFail() {
        String errorMessage = "error";
        Results<String> result = Results.fail(errorMessage);
        assertThat(result.getCode()).isEqualTo(Results.ResultCode.FAIL.getCode());
        assertThat(result.getMessage()).isEqualTo(errorMessage);
    }
}